Attribute VB_Name = "modODBCLivingston"
'---------------------------------------------------------------------------------------
'Module     : modODBC
'Author     : Joseph Weir
'Purpose    : Livingston.
'---------------------------------------------------------------------------------------

Option Explicit

#If Livingston Then

Dim m_strKeyFile As String
Dim m_strKeyValue As String
Dim m_blnProcessing As Boolean
Dim mstrIntegrationStyle As String
Dim mstrEXPORT_FILE_PATH As String
Dim mstrIMPORT_FILE_PATH As String
Dim mobjODBCProcess As frmODBCProcess
Dim mlngErrorCount As Long
' 2010-08-31, JFW, I'm getting multiple threads on Livingston server
Public g_strKeyFile As String
Public glngThreadID As Long
'


'---------------------------------------------------------------------------------------
' Procedure : AfterLoadServices()
' DateTime  : 5/17/2011
' Purpose   : Remove or add custom services.
' 2011-05-17, JFW, New for Scapa
'---------------------------------------------------------------------------------------
'
Public Sub AfterLoadServices(c1 As ComboBox)

End Sub
'

Public Function ClearCommodity() As Boolean

End Function
'

Public Function ClearShipScreen() As Boolean

    On Local Error GoTo Handler
    frmShip.f38.Text = g_clsReg.GetRegistryValue("Carry_f38", "")
    frmShip.f75.Text = g_clsReg.GetRegistryValue("Carry_f75", "")
    Exit Function
Handler:
    MsgBox Err.Description, , "modODBC.ClearShipScreen"

End Function
'

'---------------------------------------------------------------------------------------
' Procedure : Connect()
' DateTime  : 7/5/2004
' Purpose   : Open connection to ODBC test DSN. Instantiate module level recordset.
'---------------------------------------------------------------------------------------
'
Private Function Connect() As Boolean
    On Local Error GoTo Handler

    ' debugprint "modODBC.Connect"
    ' debugprint "modODBC.Connect"
    
    Connect = True

    Exit Function

Handler:
    MsgBox Err.Description, , "modODBC.Connect"

End Function
'

'---------------------------------------------------------------------------------------
' Procedure : GetData()
' DateTime  : 7/5/2004
' Purpose   : REQUIRED SUB. Called from frmShip.f1_LostFocus, which is the OrderID field.
'             Call routines needed to get data from the customer's system and assign the
'             value to the appropriate fields on the Ship form. This example uses ODBC.
'---------------------------------------------------------------------------------------
'
Public Function GetData(ByVal strKey As String) As Boolean

    On Local Error GoTo Handler

    Dim i As Long
    Dim intRecordCurrent As Long
    Dim strEmail As String
    Dim strZip As String
    Dim colRecord As New Collection
    Dim objFSO As New FileSystemObject
    Dim strLine() As String
    Dim strLine1 As String
    Dim strLine2() As String
    
    m_strKeyFile = strKey
    For i = LBound(Split(strKey, "\")) To UBound(Split(strKey, "\"))
        m_strKeyValue = UCase(Split(strKey, "\")(i))
    Next i
    m_strKeyValue = Replace(UCase(m_strKeyValue), ".TXT", "")
    
'    If g_clsReg.GetRegistryValue("IntegrationLevel", "Writeback") <> "Writeback" _
'    And g_clsReg.GetRegistryValue("IntegrationLevel", "Writeback") <> "Order Lookup" Then
'        GetData = True
'        Exit Function
'    End If

    Call DeleteIntlCommodities(m_strKeyValue)

    With objFSO.OpenTextFile(m_strKeyFile, ForReading)
        Do
            If .AtEndOfStream Then Exit Do
            strLine = Split(.ReadLine, "^")
            For i = LBound(strLine) To UBound(strLine)
                If Left(strLine(i), 2) = "FD" Then
                    strLine1 = Replace(strLine(i), "FD", "", 1, 1)
                    ' No quotes allowed in integration
                    strLine1 = Replace(strLine1, """", "`")
                    strLine1 = Replace(strLine1, "'", "`")
                    ' I'm going to split by double-quote
                    strLine1 = Replace(strLine1, ":=", """")
                    ' This will result in at least 2 parts
                    strLine2 = Split(strLine1, """")
                    If UBound(strLine2) >= 1 Then
                        
                      ' debugprint "Field " & Trim(strLine2(0)) & ", value " & Trim(strLine2(1))
                        
                        GetDataRecordAdd colRecord, Trim(strLine2(0)), Trim(strLine2(1))
                    End If
                End If
            Next i
        Loop
        .Close
    End With

    With frmShip
        If True Or GetSystemName <> "WINXPC9CA96EA3" Then
            If GetDataRecordItem(colRecord, "Shipper Post Code") <> "" Then
                If .cboLocationName(0).Text <> GetDataRecordItem(colRecord, "Shipper Post Code") Then
                    DebugPrint "Location change to " & GetDataRecordItem(colRecord, "Shipper Post Code")
                    Call frmShip.SetLocationName(GetDataRecordItem(colRecord, "Shipper Post Code"))
                    DoEvents
                    DebugPrint "Location change to " & GetDataRecordItem(colRecord, "Shipper Post Code") & ", confirm " & .cboLocationName(0).Text & ", meter " & g_str498
                    If LCase(GetDataRecordItem(colRecord, "Shipper Post Code")) <> LCase(.cboLocationName(0).Text) Then
                        Err.Raise 12345, "GetData.SetLocationName", "Invalid shipping location, " & GetDataRecordItem(colRecord, "Shipper Post Code") & "."
                    End If
                End If
            End If
        End If
        
        .f11.Text = GetDataRecordItem(colRecord, "Company Name")
        .cboCompany.Text = .f11.Text
        .f12.Text = GetDataRecordItem(colRecord, "Contact Name")
        .cboContact.Text = .f12.Text
        .f13.Text = GetDataRecordItem(colRecord, "Address 1")
        .f14.Text = GetDataRecordItem(colRecord, "Address 2")
        .f15.Text = GetDataRecordItem(colRecord, "City")
        .f16.Text = GetDataRecordItem(colRecord, "State/Province")
        .f17.Text = GetDataRecordItem(colRecord, "Zip")
        If GetDataRecordItem(colRecord, "Telephone") = "" Then
            .f18.Text = "9056772740"
        Else
            .f18.Text = GetDataRecordItem(colRecord, "Telephone")
        End If
        .f50.Text = GetDataRecordItem(colRecord, "Country")
        strZip = Left(.f17.Text, 3)

        Select Case GetDataRecordItem(colRecord, "Service Type")
        Case "GROUND"
            .f1274.Text = "92"
        Case "FREIGHT"
            .f1274.Text = "111"
        Case "EXPRESS"
            .f1274.Text = "01"
        Case Else
            .f1274.Text = "01"
        End Select

        Select Case GetDataRecordItem(colRecord, "Package Type")
        Case "Own Packaging"
            .f1273.Text = "01"
        Case Else
            .f1273.Text = "01"
        End Select
        
        Select Case GetDataRecordItem(colRecord, "UOM")
        Case "INCHES"
            .f75.Text = "lbs"
        Case Else
            .f75.Text = "lbs"
        End Select
        
        .f116.Text = GetDataRecordItem(colRecord, "Number of packages")
        .f1670.Text = GetDataRecordItem(colRecord, "Weight")
        If IsNumeric(GetDataRecordItem(colRecord, "Length")) Then
            .f59.Text = GetDataRecordItem(colRecord, "Length")
            .f58.Text = GetDataRecordItem(colRecord, "Width")
            .f57.Text = GetDataRecordItem(colRecord, "Height")
        End If
        
        .f25.Text = GetDataRecordItem(colRecord, "Customer Reference")
        .f3056.Text = GetDataRecordItem(colRecord, "Parcel ID")
        .f24.Text = Date
        If IsDate(GetDataRecordItem(colRecord, "Date")) Then
            .f24.Text = CDate(GetDataRecordItem(colRecord, "Date"))
        End If
        If CDate(.f24.Text) < Date Then .f24.Text = Date
        If GetDataRecordItem(colRecord, "Station Post Code") <> "" _
        And GetDataRecordItem(colRecord, "Shipper Post Code") <> "" Then
            If GetDataRecordItem(colRecord, "Station Post Code") <> GetDataRecordItem(colRecord, "Shipper Post Code") Then
                If GetDataRecordItem(colRecord, "Shipper Post Code") = "L5W1Y6" Then
                    .f24.Text = DateAdd("d", 1, CDate(.f24.Text))
                ElseIf GetDataRecordItem(colRecord, "Shipper Post Code") = "R3H0T8" Then
                    .f24.Text = DateAdd("d", 1, CDate(.f24.Text))
                ElseIf GetDataRecordItem(colRecord, "Shipper Post Code") = "V6W1K9" Then
                    .f24.Text = DateAdd("d", 1, CDate(.f24.Text))
                Else
                    .f24.Text = DateAdd("d", 2, CDate(.f24.Text))
                End If
            End If
        End If
        ' Push date to next workday
        Do
            If Weekday(CDate(.f24.Text)) = 1 Then
                .f24.Text = DateAdd("d", 1, CDate(.f24.Text))
            ElseIf Weekday(CDate(.f24.Text)) = 7 Then
                .f24.Text = DateAdd("d", 2, CDate(.f24.Text))
            ElseIf Month(CDate(.f24.Text)) = 7 And Day(CDate(.f24.Text)) = 1 Then
                ' Canada day
                .f24.Text = DateAdd("d", 1, CDate(.f24.Text))
            ElseIf Month(CDate(.f24.Text)) = 8 And Weekday(CDate(.f24.Text)) = 2 And Day(CDate(.f24.Text)) < 7 Then
                ' Civic day
                .f24.Text = DateAdd("d", 1, CDate(.f24.Text))
            ElseIf Month(CDate(.f24.Text)) = 9 And Weekday(CDate(.f24.Text)) = 2 And Day(CDate(.f24.Text)) < 7 Then
                ' Labour day
                .f24.Text = DateAdd("d", 1, CDate(.f24.Text))
            ElseIf Month(CDate(.f24.Text)) = 12 And Day(CDate(.f24.Text)) = 25 Then
                ' Christmas
                .f24.Text = DateAdd("d", 1, CDate(.f24.Text))
            Else
                Exit Do
            End If
        Loop
        
        Select Case GetDataRecordItem(colRecord, "Payment Type")
        Case "Prepaid"
            .f23.Text = 1
        Case Else
            .f23.Text = 1
        End Select
        
    End With

    GetData = True
Release:
    ' call kill
    Exit Function
Handler:
    g_strErrorLocation = Err.Description
    MsgBox g_strErrorLocation, , "modODBC.GetData"
    g_str2 = ""
    g_str3 = "ODBC.GetData, " & g_strErrorLocation
    Call WriteError
    ' Call Kill
    Resume Release

End Function
'


'---------------------------------------------------------------------------------------
' Procedure : GetDataReprint()
' DateTime  : 7/5/2004
' Purpose   : REQUIRED SUB. Called from frmShip.f1_LostFocus, which is the OrderID field.
'             Call routines needed to get data from the customer's system and assign the
'             value to the appropriate fields on the Ship form. This example uses ODBC.
'---------------------------------------------------------------------------------------
'
Public Function GetDataReprint(ByVal strKey As String) As String

    On Local Error GoTo Handler

    Dim i As Long
    Dim intRecordCurrent As Long
    Dim strEmail As String
    Dim strZip As String
    Dim colRecord As New Collection
    Dim objFSO As New FileSystemObject
    Dim objFile As File
    Dim strLine() As String
    Dim strLine1 As String
    Dim strLine2() As String
    Dim rs As New ADODB.Recordset
    Dim strTrackingNumber As String
    Dim strShipDate As String
    
    Dim boolLabelFile As Boolean
    Dim dtStart As Date
    Dim lngLabelCount As Long
    
    m_strKeyFile = strKey
    For i = LBound(Split(strKey, "\")) To UBound(Split(strKey, "\"))
        m_strKeyValue = UCase(Split(strKey, "\")(i))
    Next i
    m_strKeyValue = Replace(UCase(m_strKeyValue), ".TXT", "")
    m_strKeyValue = Replace(UCase(m_strKeyValue), ".txt", "")
    
'    If g_clsReg.GetRegistryValue("IntegrationLevel", "Writeback") <> "Writeback" _
'    And g_clsReg.GetRegistryValue("IntegrationLevel", "Writeback") <> "Order Lookup" Then
'        GetData = True
'        Exit Function
'    End If

    Call DeleteIntlCommodities(m_strKeyValue)

    With objFSO.OpenTextFile(m_strKeyFile, ForReading)
        Do
            If .AtEndOfStream Then Exit Do
            strLine = Split(.ReadLine, "^")
            For i = LBound(strLine) To UBound(strLine)
                If Left(strLine(i), 2) = "FD" Then
                    strLine1 = Replace(strLine(i), "FD", "", 1, 1)
                    ' No quotes allowed in integration
                    strLine1 = Replace(strLine1, """", "`")
                    strLine1 = Replace(strLine1, "'", "`")
                    ' I'm going to split by double-quote
                    strLine1 = Replace(strLine1, ":=", """")
                    ' This will result in at least 2 parts
                    strLine2 = Split(strLine1, """")
                    If UBound(strLine2) >= 1 Then
                        
                      ' debugprint "Field " & Trim(strLine2(0)) & ", value " & Trim(strLine2(1))
                        
                        GetDataRecordAdd colRecord, Trim(strLine2(0)), Trim(strLine2(1))
                    End If
                End If
            Next i
        Loop
        .Close
    End With


    Dim strSelect As String

'    If g_clsReg.GetRegistryValue("IntegrationLevel", "Writeback") <> "Writeback" Then
'        Exit Sub
'    End If

    m_strKeyValue = GetDataRecordItem(colRecord, "Parcel ID")
    
    rs.Open "select * from Shipments where g_str3056 = '" & m_strKeyValue & "' order by g_str24 desc, g_str29", g_connFSMSClient
    If Not rs.BOF Then
        ' debugprint "ODBCLivingston, GetDataReprint, get latest shipment of Parcel ID " & m_strKeyValue
        DebugPrint "ODBCLivingston, GetDataReprint, get latest shipment of Parcel ID " & m_strKeyValue
        Do
            If rs.EOF Then Exit Do
            If rs.Fields("Status").Value = "Shipped" Then
                If rs.Fields("g_str24").Value >= strShipDate Then
                    strTrackingNumber = rs.Fields("g_str29").Value
                    strShipDate = rs.Fields("g_str24").Value
                End If
            End If
            rs.MoveNext
        Loop
        If strTrackingNumber = "" Then
            g_str2 = ""
            g_str3 = "Attempted reprint of Parcel ID " & GetDataRecordItem(colRecord, "Parcel ID") & ", no valid shipments."
            Call WriteError
            GetDataReprint = "ShipError"
        Else
            dtStart = Now
            ' debugprint "ODBCLivingston, GetDataReprint, latest shipment tracking number " & strTrackingNumber
            DebugPrint "ODBCLivingston, GetDataReprint, latest shipment tracking number " & strTrackingNumber
            Set objFSO = New FileSystemObject
            If objFSO.FileExists(g_str537 & "\Save\" & m_strKeyValue & ".TXT") Then
                Set objFile = objFSO.GetFile(g_str537 & "\Save\" & m_strKeyValue & ".TXT")
                ' debugprintNow & ", ODBCLivingston, GetDataReprint, label file copy, path " & g_str537 & "\Save\" & m_strKeyValue & ".TXT"
                DebugPrint "ODBCLivingston, GetDataReprint, label file copy, path " & g_str537 & "\Save\" & m_strKeyValue & ".TXT"
                If m_strKeyValue = "" Then
                    m_strKeyValue = objFile.name
                End If
                
                lngLabelCount = 0
                Do
                    If Not objFSO.FileExists(mstrEXPORT_FILE_PATH & m_strKeyValue & IIf(lngLabelCount = 0, "", "_" & lngLabelCount) & ".TXT") Then Exit Do
                    lngLabelCount = lngLabelCount + 1
                Loop
                objFile.Copy mstrEXPORT_FILE_PATH & m_strKeyValue & IIf(lngLabelCount = 0, "", "_" & lngLabelCount) & ".TXT", True
                If Not mobjODBCProcess Is Nothing Then
                    mobjODBCProcess.mstrState = "Shipped"
                End If
                boolLabelFile = True
            Else
                g_str2 = ""
                g_str3 = "Attempted reprint of Parcel ID " & m_strKeyValue & ", label file not found, path "
                Call WriteError
                GetDataReprint = "ShipError"
            End If
            
            m_strKeyValue = ""
            GetDataReprint = "Reprinted"
            
        
        End If
    
    Else
        g_str2 = ""
        g_str3 = "Attempted reprint of Parcel ID " & m_strKeyValue & ", not found in Ship History."
        Call WriteError
        GetDataReprint = "ShipError"
    End If
    

Release:
    ' call kill
    Exit Function
Handler:
    g_str3 = "Error on Reprint, " & Err.Source & ", " & Err.Description
    g_str2 = ""
    MsgBox g_str3, , "modODBC.GetDataReprint"
    Call WriteError
    GetDataReprint = "ShipError"
    ' Call Kill
    Resume Release

End Function
'


'---------------------------------------------------------------------------------------
' Procedure : GetDataReprint095()
' DateTime  : 7/5/2004
' Purpose   : REQUIRED SUB. Called from frmShip.f1_LostFocus, which is the OrderID field.
'             Call routines needed to get data from the customer's system and assign the
'             value to the appropriate fields on the Ship form. This example uses ODBC.
'---------------------------------------------------------------------------------------
'
Public Function GetDataReprint095(ByVal strKey As String) As String

    On Local Error GoTo Handler

    Dim i As Long
    Dim intRecordCurrent As Long
    Dim strEmail As String
    Dim strZip As String
    Dim colRecord As New Collection
    Dim objFSO As New FileSystemObject
    Dim objFile As File
    Dim strLine() As String
    Dim strLine1 As String
    Dim strLine2() As String
    Dim rs As New ADODB.Recordset
    Dim strTrackingNumber As String
    Dim strShipDate As String
    
    Dim boolLabelFile As Boolean
    Dim dtStart As Date
    Dim lngLabelCount As Long
    
    m_strKeyFile = strKey
    For i = LBound(Split(strKey, "\")) To UBound(Split(strKey, "\"))
        m_strKeyValue = UCase(Split(strKey, "\")(i))
    Next i
    m_strKeyValue = Replace(UCase(m_strKeyValue), ".TXT", "")
    
'    If g_clsReg.GetRegistryValue("IntegrationLevel", "Writeback") <> "Writeback" _
'    And g_clsReg.GetRegistryValue("IntegrationLevel", "Writeback") <> "Order Lookup" Then
'        GetData = True
'        Exit Function
'    End If

    Call DeleteIntlCommodities(m_strKeyValue)

    With objFSO.OpenTextFile(m_strKeyFile, ForReading)
        Do
            If .AtEndOfStream Then Exit Do
            strLine = Split(.ReadLine, "^")
            For i = LBound(strLine) To UBound(strLine)
                If Left(strLine(i), 2) = "FD" Then
                    strLine1 = Replace(strLine(i), "FD", "", 1, 1)
                    ' No quotes allowed in integration
                    strLine1 = Replace(strLine1, """", "`")
                    strLine1 = Replace(strLine1, "'", "`")
                    ' I'm going to split by double-quote
                    strLine1 = Replace(strLine1, ":=", """")
                    ' This will result in at least 2 parts
                    strLine2 = Split(strLine1, """")
                    If UBound(strLine2) >= 1 Then
                        
                        ' debugprint "Field " & Trim(strLine2(0)) & ", value " & Trim(strLine2(1))
                        
                        GetDataRecordAdd colRecord, Trim(strLine2(0)), Trim(strLine2(1))
                    End If
                End If
            Next i
        Loop
        .Close
    End With


    Dim strSelect As String

'    If g_clsReg.GetRegistryValue("IntegrationLevel", "Writeback") <> "Writeback" Then
'        Exit Sub
'    End If

    rs.Open "select * from Shipments where g_str3056 = '" & GetDataRecordItem(colRecord, "Parcel ID") & "' order by g_str24 desc, g_str29", g_connFSMSClient
    If Not rs.BOF Then
        Do
            If rs.EOF Then Exit Do
            If rs.Fields("Status").Value = "Shipped" Then
                If rs.Fields("g_str24").Value >= strShipDate Then
                    strTrackingNumber = rs.Fields("g_str29").Value
                    strShipDate = rs.Fields("g_str24").Value
                End If
            End If
            rs.MoveNext
        Loop
        If strTrackingNumber = "" Then
            g_str2 = ""
            g_str3 = "Attempted reprint of Parcel ID " & GetDataRecordItem(colRecord, "Parcel ID") & ", no valid shipments."
            Call WriteError
            GetDataReprint095 = "ShipError"
        Else
            ' Reprint
            Call SendData(BuildLabelReprintTrans(strTrackingNumber))
        
        
        
                
            dtStart = Now
            Set objFSO = New FileSystemObject
            
            Do
                If boolLabelFile Then Exit Do
                If DateAdd("s", 20, dtStart) < Now Then
                    DebugPrint "ODBCLivingston, Reprint, Timeout awaiting "
                    g_str2 = ""
                    g_str3 = "Timeout awaiting label file from server."
                    Call WriteError
                    Exit Do
                End If
                ' Some delay
                For i = 1 To 500
                    DoEvents
                Next i
                ' Check for output folder
                Call WriteExportFolder
                ' Look for label file
                For Each objFile In objFSO.GetFolder(g_str537).Files
                    If LCase(Right(objFile.name, 4)) = "." & g_str187 Then
                        ' debugprintNow & ", ODBCLivingston, Reprint, label file copy."
                        DebugPrint "ODBCLivingston, Reprint, label file copy."
                        If m_strKeyValue = "" Then
                            m_strKeyValue = objFile.name
                        End If
                        
                        lngLabelCount = 0
                        Do
                            If Not objFSO.FileExists(mstrEXPORT_FILE_PATH & m_strKeyValue & IIf(lngLabelCount = 0, "", "_" & lngLabelCount) & ".TXT") Then Exit Do
                            lngLabelCount = lngLabelCount + 1
                        Loop
                        objFile.Copy mstrEXPORT_FILE_PATH & m_strKeyValue & IIf(lngLabelCount = 0, "", "_" & lngLabelCount) & ".TXT", True
                        objFile.Delete True
                        If Not mobjODBCProcess Is Nothing Then
                            mobjODBCProcess.mstrState = "Shipped"
                        End If
                        boolLabelFile = True
                    End If
                Next objFile
            Loop
            
            m_strKeyValue = ""
            GetDataReprint095 = "Reprinted"
            
        
        End If
    
    Else
        g_str2 = ""
        g_str3 = "Attempted reprint of Parcel ID " & GetDataRecordItem(colRecord, "Parcel ID") & ", not found in Ship History."
        Call WriteError
        GetDataReprint095 = "ShipError"
    End If
    

Release:
    ' call kill
    Exit Function
Handler:
    g_str3 = "Error on Reprint, " & Err.Source & ", " & Err.Description
    g_str2 = ""
    MsgBox g_str3, , "modODBC.GetDataReprint095"
    Call WriteError
    GetDataReprint095 = "ShipError"
    ' Call Kill
    Resume Release

End Function
'

' Safely add to a collection
Private Function GetDataRecordAdd(col As Collection, strKey As String, strValue As String)
    On Error Resume Next
    If col Is Nothing Then Set col = New Collection
    col.Add strValue, strKey
End Function
'

' Safely get an item of a collection
Private Function GetDataRecordItem(col As Collection, strKey As String) As Variant
    On Error Resume Next
    If col Is Nothing Then Set col = New Collection
    GetDataRecordItem = col.item(strKey)
End Function
'

'---------------------------------------------------------------------------------------
' Procedure : GetPickupData()
' DateTime  : 1/30/2006
' Purpose   : REQUIRED SUB. Called from frmAddTags.f1_LostFocus, which is the OrderID field.
'             Call routines needed to get data from the customer's system and assign the
'             value to the appropriate fields on the Ship form. This example uses ODBC.
'---------------------------------------------------------------------------------------
'
Public Function GetPickupData(ByVal strKey As String) As Boolean

    On Error Resume Next

    GetPickupData = True

End Function


Private Sub WriteExportFolder()

    On Local Error GoTo Handler

    Dim objFSO As New FileSystemObject
    
    If GetSystemName = "CAN00283812" Then
        g_clsSettings.Setting("ExportFolder") = "C:\Documents and Settings\271425\My Documents\CUSTOMERDATA\CUSTOMERDATA\Livingston\"
    
        If Not objFSO.FolderExists(g_clsSettings.Setting("ExportFolder")) Then
            objFSO.CreateFolder g_clsSettings.Setting("ExportFolder")
        End If
    
    ElseIf GetSystemName = "WINXPC9CA96EA3" Then
        g_clsSettings.Setting("ExportFolder") = "C:\Documents and Settings\563774\My Documents\FXI\Projects\Meena\Livingston\Label\"
    
        If Not objFSO.FolderExists(g_clsSettings.Setting("ExportFolder")) Then
            objFSO.CreateFolder g_clsSettings.Setting("ExportFolder")
        End If
    
    End If
    
    mstrEXPORT_FILE_PATH = g_clsSettings.Setting("ExportFolder")
    If mstrEXPORT_FILE_PATH = "" Then
        If GetSystemName = "CAN00283812" Then
            g_clsSettings.Setting("ExportFolder") = "C:\Documents and Settings\271425\My Documents\CUSTOMERDATA\CUSTOMERDATA\Livingston\"
        ElseIf GetSystemName = "WINXPC9CA96EA3" Then
            g_clsSettings.Setting("ExportFolder") = "C:\Documents and Settings\563774\My Documents\FXI\Projects\Meena\Livingston\Label\"
        Else
            g_clsSettings.Setting("ExportFolder") = "\\tpcathena\Public\Navision\FedEx\Out\"
        End If
        g_clsSettings.SaveSettings
        mstrEXPORT_FILE_PATH = g_clsSettings.Setting("ExportFolder")
        frmMsgBox.ShowMessage "Configuration file (FSMSClient.xml) updated with ExportFolder.", 8000
    End If
    Exit Sub
Handler:
    MsgBox Err.Description, , "modODBC.WriteExportFolder"

End Sub
'

'---------------------------------------------------------------------------------------
' Procedure : WriteReply()
' DateTime  : 2/14/2005
' Purpose   : REQUIRED SUB. Called after a successful ship transaction.
'             This example shows how to obtain multiple occurrence fields from the
'             FXRS reply and how to obtain multiple occurrence fields included in the
'             input transaction but not returned in the FXRS reply.
'---------------------------------------------------------------------------------------
'
Public Sub WriteReply()

    On Error GoTo Cafe_AfterShipment_Error

    Dim objFSO As FileSystemObject
    Dim objFile As File
    Dim strMiscellaneousPaymentType As String
    Dim strRecord As String
    Dim strFilename As String
    Dim strFilenameSave As String
    Dim i As Long
    Dim boolLabelFile As Boolean
    Dim dtStart As Date
    Dim lngLabelCount As Long
    
    dtStart = Now
    Set objFSO = New FileSystemObject
    
    Do
        If boolLabelFile Then Exit Do
        If DateAdd("s", 20, dtStart) < Now Then
            DebugPrint "ODBCLivingston, WriteReply, Timeout awaiting "
            g_str2 = ""
            g_str3 = "Timeout awaiting label file from server."
            Call WriteError
            Exit Do
        End If
        ' Some delay
        For i = 1 To 500
            DoEvents
        Next i
        ' Check for output folder
        Call WriteExportFolder
        ' Look for label file
        For Each objFile In objFSO.GetFolder(g_str537).Files
            If LCase(Right(objFile.name, 4)) = "." & g_str187 Then
                
                strFilenameSave = g_str537
                If Not objFSO.FolderExists(g_str537 & "\Save") Then
                    On Error Resume Next
                    objFSO.CreateFolder g_str537 & "\Save"
                    Err.Clear
                    On Error GoTo Cafe_AfterShipment_Error
                End If
                If objFSO.FolderExists(g_str537 & "\Save") Then
                    ' Copy label file to Save folder
                    ' debugprint "ODBCLivingston, WriteReply, label save, from " & objfile.Path & " to " & g_str537 & "\Save\" & m_strKeyValue & ".TXT"
                    DebugPrint "ODBCLivingston, WriteReply, label save, from " & objFile.Path & " to " & g_str537 & "\Save\" & m_strKeyValue & ".TXT"
                    If m_strKeyValue = "" Then
                        m_strKeyValue = objFile.name
                    End If
                    lngLabelCount = 0
                    Do
                        If Not objFSO.FileExists(g_str537 & "\Save\" & m_strKeyValue & IIf(lngLabelCount = 0, "", "_" & lngLabelCount) & ".TXT") Then Exit Do
                        lngLabelCount = lngLabelCount + 1
                    Loop
                    If lngLabelCount > 0 Then
                        DebugPrint "ODBCLivingston, WriteReply, Export file label copy, incremental label, file " & g_str537 & "\Save\" & m_strKeyValue & IIf(lngLabelCount = 0, "", "_" & lngLabelCount) & ".TXT"
                    End If
                    objFile.Copy g_str537 & "\Save\" & m_strKeyValue & IIf(lngLabelCount = 0, "", "_" & lngLabelCount) & ".TXT", True
                End If
                
                On Error GoTo Cafe_AfterShipment_Error
                
                ' Copy label file to Livingston integraqtion folder
                ' debugprint "ODBCLivingston, WriteReply, label copy, from " & objfile.Path & " to " & mstrEXPORT_FILE_PATH & m_strKeyValue & ".TXT"
                DebugPrint "ODBCLivingston, WriteReply, label copy, from " & objFile.Path & " to " & mstrEXPORT_FILE_PATH & m_strKeyValue & ".TXT"
                If m_strKeyValue = "" Then
                    m_strKeyValue = objFile.name
                End If
                lngLabelCount = 0
                Do
                    If Not objFSO.FileExists(mstrEXPORT_FILE_PATH & m_strKeyValue & IIf(lngLabelCount = 0, "", "_" & lngLabelCount) & ".TXT") Then Exit Do
                    lngLabelCount = lngLabelCount + 1
                Loop
                If lngLabelCount > 0 Then
                    DebugPrint "ODBCLivingston, WriteReply, Export file label copy, incremental label, file " & mstrEXPORT_FILE_PATH & m_strKeyValue & IIf(lngLabelCount = 0, "", "_" & lngLabelCount) & ".TXT"
                End If
                objFile.Copy mstrEXPORT_FILE_PATH & m_strKeyValue & IIf(lngLabelCount = 0, "", "_" & lngLabelCount) & ".TXT", True
                
                objFile.Delete True
                
                If objFSO.FileExists(mstrEXPORT_FILE_PATH & m_strKeyValue & IIf(lngLabelCount = 0, "", "_" & lngLabelCount) & ".TXT") Then
                    DebugPrint "ODBCLivingston, WriteReply, Export file label confirmed, path " & objFSO.GetFile(mstrEXPORT_FILE_PATH & m_strKeyValue & IIf(lngLabelCount = 0, "", "_" & lngLabelCount) & ".TXT").Path
                Else
                    DebugPrint "ODBCLivingston, WriteReply, Export file label failed, file not found, path " & objFSO.GetFile(mstrEXPORT_FILE_PATH & m_strKeyValue & IIf(lngLabelCount = 0, "", "_" & lngLabelCount) & ".TXT").Path
                End If
                
                If Not mobjODBCProcess Is Nothing Then
                    mobjODBCProcess.mstrState = "Shipped"
                End If
                boolLabelFile = True
            End If
        Next objFile
    Loop
    
    m_strKeyValue = ""
    
    strRecord = ""

Release:
    m_strKeyValue = ""

    Exit Sub

Cafe_AfterShipment_Error:
    MsgBox Err.Description & " (WriteReply)", vbSystemModal
    If False Then
        Resume
    End If

End Sub
'---------------------------------------------------------------------------------------
' Procedure : WriteReturnReply()
' DateTime  : 7/14/2005
' Purpose   : REQUIRED SUB. Called after a successful return label transaction.
'             This is called for both regular and online return labels.
'---------------------------------------------------------------------------------------
'
Public Sub WriteReturnReply()

End Sub
'---------------------------------------------------------------------------------------
' Procedure : WriteBOLReply()
' DateTime  : 1/11/2006
' Purpose   : REQUIRED SUB. Called after a successful FedEx Freight BOL transaction.
'             This is called for both regular and online return labels.
'---------------------------------------------------------------------------------------
'
Public Sub WriteBOLReply()

End Sub
'---------------------------------------------------------------------------------------
' Procedure : WriteBatchEditReply()
' DateTime  : 1/17/2006
' Purpose   : REQUIRED SUB. Called after a successful Batch Error Edit transaction.
'             This is called for both regular and online return labels.
'---------------------------------------------------------------------------------------
'
Public Sub WriteBatchEditReply()

End Sub
' Procedure : WriteTagReply()
' DateTime  : 1/26/2006
' Purpose   : REQUIRED SUB. Called after a successful Call Tag/Express Tag transaction.
'---------------------------------------------------------------------------------------
'
Public Sub WriteTagReply()

End Sub
' Procedure : WriteCancelTagReply()
' DateTime  : 1/26/2006
' Purpose   : REQUIRED SUB. Called after a successful Cancel Call Tag/Express Tag transaction.
'---------------------------------------------------------------------------------------
'
Public Sub WriteCancelTagReply()

End Sub
'---------------------------------------------------------------------------------------
' Procedure : WriteReturnDelete()
' DateTime  : 7/14/2005
' Purpose   : REQUIRED SUB. Called after a successful return label delete transaction.
'             This is called for both regular and online return labels.
'---------------------------------------------------------------------------------------
'
Public Sub WriteReturnDelete(ByVal strTracking As String)

End Sub
'---------------------------------------------------------------------------------------
' Procedure : WriteError()
' DateTime  : 7/5/2004
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed after
'             an FXRS Error reply transaction.
'---------------------------------------------------------------------------------------
'
Public Sub WriteError()
    
    On Local Error GoTo Handler
    
    Dim objFSO As FileSystemObject
    Dim objFile As File
    Dim strMiscellaneousPaymentType As String
    Dim strRecord As String
    Dim strFilename As String
    
    MsgBox "Shipping Error: " & g_str3, vbCritical, "FSMS Error"
    
    ' debugprint "Error label being created, file " & mstrEXPORT_FILE_PATH & m_strKeyValue & ".TXT"
    DebugPrint "Error label being created, file " & mstrEXPORT_FILE_PATH & m_strKeyValue & ".TXT"
    
    Call WriteExportFolder
    
    Set objFSO = New FileSystemObject
    mlngErrorCount = mlngErrorCount + 1
    If m_strKeyValue = "" Then
        m_strKeyValue = Format(Now, "mmddyyHHmmss") & Format(mlngErrorCount, "000000") & ".288"
    End If
    
    If objFSO.FileExists(mstrEXPORT_FILE_PATH & m_strKeyValue & ".TXT") Then
        objFSO.DeleteFile mstrEXPORT_FILE_PATH & m_strKeyValue & ".TXT", True
    End If
    
    With objFSO.CreateTextFile(mstrEXPORT_FILE_PATH & m_strKeyValue & ".TXT", True)
            
        .WriteLine "^XA^CF,0,0,0^PR12^MD30^PW800^POI^CI13^LH0,20"
        .WriteLine "^FO10,308^GB790,2,2^FS"
        .WriteLine "^FO10,565^GB790,2,2^FS"
        .WriteLine "^FO477,162^GB2,146,2^FS"
        .WriteLine "^FO35,169^AdN,0,0^FWN^FH^FDORIGIN ID: " & frmShip.cboLocationName(0).Text & "^FS"
        .WriteLine "^FO35,188^AdN,0,0^FWN^FH^FD" & g_str32 & "^FS"
        .WriteLine "^FO35,208^AdN,0,0^FWN^FH^FD" & g_str4 & "^FS"
        .WriteLine "^FO35,228^AdN,0,0^FWN^FH^FD" & g_str5 & "^FS"
        .WriteLine "^FO35,249^AdN,0,0^FWN^FH^FD" & g_str6 & "^FS"
        .WriteLine "^FO35,269^AdN,0,0^FWN^FH^FD" & g_str7 & ", " & g_str8 & " " & g_str9 & "^FS"
        .WriteLine "^FO35,289^AdN,0,0^FWN^FH^FD" & IIf(g_str117 = "CA", "CANADA ", IIf(g_str117 = "US", "UNITED STATES ", "")) & g_str117 & "^FS"
        .WriteLine "^FO490,169^AdN,0,0^FWN^FH^FDShip Date: " & g_str24 & "^FS"
        .WriteLine "^FO490,208^AdN,0,0^FWN^FH^FDCAD: " & g_str498 & "/FSMS^FS"
        If g_str23 = "2" Then
            .WriteLine "^FO490,228^AdN,0,0^FWN^FH^FDAccount: R " & g_str23 & "^FS"
        ElseIf g_str23 = "3" Then
            .WriteLine "^FO490,228^AdN,0,0^FWN^FH^FDAccount: T " & g_str23 & "^FS"
        Else
            .WriteLine "^FO490,228^AdN,0,0^FWN^FH^FDAccount: S " & g_str10 & "^FS"
        End If
        .WriteLine "^FO10,324^A0N,20,18^FWN^FH^FDTO^FS"
        .WriteLine "^FO520,318^AdN,0,0^FWN^FH^FD" & g_str183 & "^FS"
        .WriteLine "^FO43,320^A0N,25,27^FWN^FH^FD" & g_str12 & "^FS"
        .WriteLine "^FO43,355^A0N,25,27^FWN^FH^FD" & g_str11 & "^FS"
        .WriteLine "^FO43,390^A0N,25,27^FWN^FH^FD" & g_str13 & "^FS"
        .WriteLine "^FO43,425^A0N,25,27^FWN^FH^FD" & g_str14 & "^FS"
        .WriteLine "^FO43,458^A0N,30,30^FWN^FH^FD" & g_str15 & ", " & g_str16 & " " & g_str17 & "^FS"
        .WriteLine "^FO16,545^A0N,15,15^FWN^FH^FDREF: " & g_str25 & "^FS"
        .WriteLine "^FO10,714^A0N,20,18^FWN^FH^FDError1:" & g_str2 & "^FS"
        .WriteLine "^FO10,744^A0N,20,18^FWN^FH^FDError2:" & g_str3 & "^FS"
        .WriteLine "^FO100,764^A0N,20,18^FWN^FH^FD^FS"
        .WriteLine "^FO100,784^A0N,20,18^FWN^FH^FD^FS"
        .WriteLine "^FO100,804^A0N,20,18^FWN^FH^FD^FS"
        ' .WriteLine "^FO255,864^A0N,20,18^FWN^FH^FD FSMTRANSIN^FS"
        .WriteLine "^FO125,580^A0N,75,90^FWN^FH^FDDO NOT SHIP^FS"
        .WriteLine "^FO10,684^A0N,20,18^FWN^FH^FDError Detected During Processing^FS"
        .WriteLine "^FO35,864^A0N,20,18^FWN^FH^FDTransaction ID:" & m_strKeyValue & "^FS"
        .WriteLine "^FO670,430^GB105,10,10^FS"
        .WriteLine "^FO670,440^GB10,112,10^FS"
        .WriteLine "^FO765,440^GB10,112,10^FS"
        .WriteLine "^FO670,552^GB105,10,10^FS"
        .WriteLine "^FO650,350^A0N,50,55^FWN^FH^FDFedEx^FS"
        .WriteLine "^FO715,393^AdN,0,0^FWN^FH^FD^FS"
        .WriteLine "^FO690,448^A0N,130,130^FWN^FH^FDE^FS"
        .WriteLine "^FO783,480^A0N,15,15^FWB^FH^FDJ092009113006^FS"
        .WriteLine "^FO490,188^AdN,0,0^FWN^FH^FDActual Wgt: " & g_str1670 & " ^FS"
        .WriteLine "^FO550,467^A0N,35,45^FWN^FH^FD(" & g_str50 & ")^FS"
        .WriteLine "^PQ1"
        .WriteLine "^XZ"
          
        .Close
    End With
    
    If Not mobjODBCProcess Is Nothing Then mobjODBCProcess.mstrState = "ShipError"
    
    m_strKeyValue = ""
    Exit Sub
Handler:
    MsgBox Err.Description, , "modODBC.WriteError"

End Sub
'

'---------------------------------------------------------------------------------------
' Procedure : WriteDelete()
' DateTime  : 7/5/2004
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed after
'             successful FXRS Delete.
' Called    : frmShip g_clsParser_Parsecomplete() event on FSMS 123 reply
'---------------------------------------------------------------------------------------
'
Public Sub WriteDelete(ByVal strTracking As String)

End Sub
'---------------------------------------------------------------------------------------
' Procedure : AfterClose()
' DateTime  : 7/5/2004
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed after
'             FXRS Close.
'---------------------------------------------------------------------------------------
'
Public Sub AfterClose()

End Sub
'

' 2007-04-13, JFW, Allow for custom screen display.
Public Sub AfterConnect()

    On Local Error GoTo Handler

    ' 2007-12-07, JFW, Large address book making a slow start on some clients.
    ' Call frmShip.ToggleLookup(True)
    On Error Resume Next
    'Call frmShip.ToggleDepartment(True)
    frmShip.f70.ListIndex = 0
    frmShip.f72.ListIndex = 0
    frmShip.f38 = g_clsReg.GetRegistryValue("Carry_f38", "")
    frmShip.f75 = g_clsReg.GetRegistryValue("Carry_f75", "")

    If Not mobjODBCProcess Is Nothing Then mobjODBCProcess.mstrState = "Connect"
    Exit Sub
Handler:
    MsgBox Err.Description, , "modODBC.AfterConnect"
    
End Sub
'


' 2007-04-13, JFW, Allow for custom screen display.
Public Sub AfterDisconnect()

    On Error Resume Next

    If Not mobjODBCProcess Is Nothing Then mobjODBCProcess.mstrState = "Start"
    
End Sub
'

'---------------------------------------------------------------------------------------
' Procedure : BeforeClose()
' DateTime  : 7/12/2006
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed before
'             FXRS Close.
'---------------------------------------------------------------------------------------
'
Public Function BeforeClose() As Boolean

    On Error Resume Next

    BeforeClose = True

End Function
'

'---------------------------------------------------------------------------------------
' Procedure : BeforeShip()
' DateTime  : 2/21/2005
' Purpose   : REQUIRED Function. Modified to Return Boolean which controls whether or not
'             the shipment will continue or be canceled. Return True to continue shipment,
'             False to cancel.
'---------------------------------------------------------------------------------------
'
Public Function BeforeShip(Optional ByRef TransString As String = "") As Boolean

    On Error Resume Next

    BeforeShip = True

End Function
'

'---------------------------------------------------------------------------------------
' Procedure : BeforeShipTrans()
' DateTime  : 8/7/2008
' Purpose   : REQUIRED Function. Modified to Return Boolean which controls whether or not
'             the shipment will continue or be canceled. Return True to continue shipment,
'             False to cancel.
'---------------------------------------------------------------------------------------
'
Public Function BeforeShipTrans(ByRef TransString As String) As Boolean
    
    On Error Resume Next
    
    Dim lngMsgBoxResult As VbMsgBoxResult
    BeforeShipTrans = True
    
End Function
'


'---------------------------------------------------------------------------------------
' Procedure : Initialize()
' DateTime  : 7/5/2004
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed on
'             program execution.
'---------------------------------------------------------------------------------------
'
Public Sub Initialize(Optional f1 As Form)

    On Error Resume Next

    If Not f1 Is Nothing Then
        If f1.name = "frmShip" Then
            
            If Not mobjODBCProcess Is Nothing Then
                Unload mobjODBCProcess
                Set mobjODBCProcess = Nothing
            End If
            Set mobjODBCProcess = New frmODBCProcess
            Load mobjODBCProcess
            mobjODBCProcess.Hide
        End If
    End If
    
End Sub
'---------------------------------------------------------------------------------------
' Procedure : BeforeBatch()
' DateTime  : 20070621-01 Changed BeforeBatch to return a boolean
' Purpose   : REQUIRED SUB. Called before an entire batch is processed.
'---------------------------------------------------------------------------------------
'
Public Function BeforeBatch() As Boolean

    On Error Resume Next

    BeforeBatch = True

End Function
'---------------------------------------------------------------------------------------
' Procedure : BeforeBatchShip()
' DateTime  : 20070822-02 Modified BeforeBatchShip to return a Boolean.
' Purpose   : REQUIRED SUB. Called just before a batch transaction is sent to the server.
'---------------------------------------------------------------------------------------
'
Public Function BeforeBatchShip() As Boolean

    On Error Resume Next

    BeforeBatchShip = True

End Function
'---------------------------------------------------------------------------------------
' Procedure : AfterBatchShip()
' DateTime  : 10/28/2005
' Purpose   : REQUIRED SUB. Called just after a batch transaction has been processed.
'---------------------------------------------------------------------------------------
'
Public Sub AfterBatchShip()

End Sub
'---------------------------------------------------------------------------------------
' Procedure : AfterBatch()
' DateTime  : 4/6/2005
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed after
'             a batch shipment has been completed.
'---------------------------------------------------------------------------------------
'
Public Sub AfterBatch()

End Sub
'---------------------------------------------------------------------------------------
' Procedure : AfterAddrLookup()
' DateTime  : 2/21/2005
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed after
'             cboCustID, cboContact, or cboCompany loses focus.
'---------------------------------------------------------------------------------------
'
Public Sub AfterAddrLookup()
    On Error Resume Next
    frmShip.f25.SetFocus
End Sub
'---------------------------------------------------------------------------------------
' Procedure : AfterDeptLostFocus()
' DateTime  : 2/21/2005
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed after
'             f38 loses focus.
'---------------------------------------------------------------------------------------
'
Public Sub AfterDeptLostFocus()

    On Error Resume Next
    g_clsReg.SetRegistryValue "Carry_f38", frmShip.f38, REG_SZ

End Sub
'---------------------------------------------------------------------------------------
' Procedure : AfterAddrVerifyUpdate()
' DateTime  : 9/13/2005
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed after
'             an address has been updated on the Ship form.
'---------------------------------------------------------------------------------------
'
Public Sub AfterAddrVerifyUpdate()

End Sub

' 2011-02-01, JFW, Clear DG disclaimer automatically.
Public Function AfterDGDisclaimer() As Boolean
    AfterDGDisclaimer = True
End Function


'---------------------------------------------------------------------------------------
' Procedure : AfterLocationChange()
' DateTime  : 3/06/2006
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed after
'             the shipping Location has been changed on the Ship form.
'---------------------------------------------------------------------------------------
'
Public Sub AfterLocationChange()

    On Local Error GoTo Handler

    DebugPrint "Integration, AfterLocationChange, meter " & g_str498
    
    mstrIntegrationStyle = g_clsSettings.Setting("IntegrationStyle" & frmShip.cboLocationName(0).Text)
    If mstrIntegrationStyle = "" Then
        g_clsSettings.Setting("IntegrationStyle" & frmShip.cboLocationName(0).Text) = "EXPRESS"
        g_clsSettings.SaveSettings
        mstrIntegrationStyle = g_clsSettings.Setting("IntegrationStyle" & frmShip.cboLocationName(0).Text)
        frmMsgBox.ShowMessage "Integration style created for location " _
            & frmShip.cboLocationName(0).Text _
            & " default to " & mstrIntegrationStyle & ".", 8000
    End If
    Exit Sub
Handler:
    MsgBox Err.Description, , "modODBC.AfterLocationChange"

End Sub
'

'---------------------------------------------------------------------------------------
' Procedure : AfterAddrVerify()
' DateTime  : 5/12/2006
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed after
'             Address Verification. Three possible status codes are passed. See comments
'             below.
'---------------------------------------------------------------------------------------
'
Public Sub AfterAddrVerify(ByVal intStatusCode As Integer)

    On Error Resume Next

    Select Case intStatusCode
        'Address is verfified
        Case 1

        'Soft error
        Case 2

        'Hard error
        Case 3

    End Select

End Sub
'---------------------------------------------------------------------------------------
' Procedure : BuildCustomSPLabel()
' DateTime  : 20070620-04
' Purpose   : REQUIRED SUB. Can be used as hook to create custom EPL or ZPL buffer labels
'             for SmartPost.
'---------------------------------------------------------------------------------------
'
Public Function BuildCustomSPLabel(ByVal strLabel As String) As String

    On Error Resume Next

    BuildCustomSPLabel = strLabel

End Function
'


'---------------------------------------------------------------------------------------
' Procedure : AfterLostFocus()
' DateTime  : 2/21/2005
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed after
'             cboDept or f38 loses focus.
'---------------------------------------------------------------------------------------
'
Public Sub AfterLostFocus(c1 As Control)
    
End Sub
'

'---------------------------------------------------------------------------------------
' Procedure : AfterRateQuote()
' DateTime  : 20071106-01
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed after
'             a rate quote.
'---------------------------------------------------------------------------------------
'
Public Sub AfterRateQuote()

End Sub
'


'---------------------------------------------------------------------------------------
' Procedure : MsgBox()
' DateTime  : 2010-07-18
' Purpose   : Optional function.  Override all uses of MsgBox.  Livingston runs lights out.
'---------------------------------------------------------------------------------------
'
Public Function MsgBox(strPrompt As String, Optional lngMsgBoxStyle As VbMsgBoxStyle = vbOKOnly, Optional strTitle As String = "") As VbMsgBoxResult

    On Error Resume Next

    ' This is what all other integrations do (by omission)
    ' MsgBox = Interaction.MsgBox(strPrompt, lngMsgBoxStyle, strTitle)
        
    ' debugprint IIf(strTitle <> "", strTitle & ", ", "") & strPrompt
    DebugPrint IIf(strTitle <> "", strTitle & ", ", "") & strPrompt
    If (lngMsgBoxStyle And vbYesNo) = vbYesNo Then
        MsgBox = vbYes
    End If
    
End Function
'

#End If



